import random
from Solution import Solution

def count3(n):
    if n <= 0:
        return 0

    count = 0
    i = 1
    while n // i != 0:
        count += (n // i // 10) * i
        current = (n // i) % 10
        if current > 3:
            count += i
        elif current == 3:
            count += n - (n // i) * i + 1
        i *= 10

    return count

s = Solution()
numbers = [random.randrange(1000000, 100000000) for i in range(10)]
numbers.extend([0, 1, 2])
for i in range(13):
    number = numbers[i]
    a = s.answer(number)
    e = count3(number)
    if a != e:
        print("Test Failed\nInput:", number, "Expected:", e, "Got:", a)
        exit(1)

exit(0)